<template>
  <el-card>
    <h1>用户登录</h1>
    <el-form>
      <el-form-item label="用户名">
        <el-input v-model="username" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script lang="ts">
export default {
  name: "Login",
};
</script>

<script lang="ts" setup>
import { ref } from "vue";
import { useRouter } from "vue-router";

const username = ref("");

const router = useRouter();

const login = () => {
  if (!username.value) return;
  localStorage.setItem("username", username.value);
  router.push("/");
};
</script>

<style scoped></style>
